package com.example.demo.controller;

import com.example.demo.entity.DTO.LoadMessageDTO;
import com.example.demo.entity.Result;
import com.example.demo.entity.User;
import com.example.demo.service.IMessageService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yolo
 * @since 2025-03-28
 */
@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    IMessageService messageService;

    @PostMapping("getUnReadMessageListByUsername")
    public Result getUnReadMessageListByUsername(@RequestBody User user){
        return messageService.getUnReadMessageListByUsername(user.getUsername());
    }

    @PostMapping("getChatMessageByMutualUsername")
    public Result getChatMessageByMutualUsername(@RequestBody LoadMessageDTO loadMessageDTO){
        return messageService.getChatMessageByMutualUsername(loadMessageDTO);
    }

    @PostMapping("getChatList")
    public Result getChatList(@RequestBody LoadMessageDTO loadMessageDTO){
        return messageService.getChatList(loadMessageDTO);
    }

    @PostMapping("getUnreadCountList")
    public Result getUnreadCountList(@RequestBody LoadMessageDTO loadMessageDTO){
        return messageService.getUnreadCountList(loadMessageDTO);
    }

    @PostMapping("getUnreadCount")
    public Result getUnreadCount(@RequestBody LoadMessageDTO loadMessageDTO){
        return messageService.getUnreadCount(loadMessageDTO.getCurrentUsername());
    }
}
